package com.itxx.keyCase.demo1;

import com.itxx.collection.test.domain.Student;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

//重点 案例

public class Test1 {
    public static void main(String[] args) {
        Collection<Student> list = new ArrayList<>();
        list.add(new Student("刘飞", 30, "男"));
        list.add(new Student("关备", 31, "男"));
        list.add(new Student("张羽", 32, "男"));
        list.add(new Student("赵超", 33, "男"));
        list.add(new Student("马云", 34, "男"));
        list.add(new Student("司马懿", 34, "男"));
        list.add(new Student("太史慈", 34, "男"));
        list.add(new Student("公孙瓒", 34, "男"));

        Iterator<Student> iterator = list.iterator();

        System.out.println();
        //通过while循环遍历集合
        while (iterator.hasNext()) {
            // i.next()   获取当前元素   并指向下一个索引
            Student s = iterator.next();
            System.out.println(s);
        }
    }

}
